<template>
    <!-- use the modal component, pass in the prop -->
    <modal v-if="stateManager.InfoDialogVisible"
           @cancel="closeDialog"
           @ok="closeDialog"
           :modal-title="modalTitle"
           model-size="normal">
        <!--
          you can use custom content here to overwrite
          default content
        -->
        <div class="row">
            <div class="col-xs-12">
                <div class="table-responsive">
                    <table class="table table-striped">
                        <tbody>
                        <tr>
                            <td>课程名称</td><td>{{model.e_name}}</td>
                        </tr>
                        <tr>
                            <td>考生姓名</td><td>{{model.students.u_name}}</td>
                        </tr>
                        <tr>
                            <td>考生学号</td><td>{{model.students.u_code}}</td>
                        </tr>
                        <tr>
                            <td>学期</td><td>{{$store.state.years[model.semester_id]}}</td>
                        </tr>
                        <tr>
                            <td>课程号</td><td>{{model.e_number}}</td>
                        </tr>
                        <tr>
                            <td>课序号</td><td>{{model.serial_number}}</td>
                        </tr>
                        <tr>
                            <td>考试成绩</td><td>{{model.e_codes}}</td>
                        </tr>
                        <tr>
                            <td>基点成绩</td><td>{{model.e_jd_codes}}</td>
                        </tr>
                        <tr>
                            <td>考试时间</td><td>{{changeTime(model.time)}}</td>
                        </tr>
                        <tr>
                            <td>学分</td><td>{{model.credit}}</td>
                        </tr>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </modal>


</template>

<script>
    export default {
        props: {
            stateManager: {
                type: Object
            }
        },
        data: function () {
            return {
                model: this.$modelDataSource({
                    url: 'api/english/english-list',
                    dataKey: 'model',
                    attributes: {
                        id: 0,
                        e_number:'',
                        semester_id:'',
                        serial_number:'',
                        e_code:'',
                        e_name:'',
                        students:{},
                        e_codes:'',
                        time:'',
                        credit:''
                    }
                })
            };
        },
        methods: {
            changeTime:function (time) {
                return new Date(parseInt(time) * 1000).toLocaleString().replace(/:\d{1,2}$/,' ');
            },
            closeDialog: function () {
//                console.log(11);
                this.stateManager.InfoDialogVisible = false;
                this.stateManager.InfoModelId = 0;
            }
        },
        computed: {
            modalTitle: function () {
                return '查看成绩'
            }
        },
        watch: {
            'stateManager.InfoModelId': function (newValue) {
                this.model.fetch(newValue);
            }
        }
    }
</script>
<style>
</style>